﻿using Microsoft.Win32;
using System.CodeDom.Compiler;

namespace TgaScanner
{
    internal class SelectDirectoryCommand : BaseCommand
    {
        private readonly MainWindowViewModel viewModel;

        public SelectDirectoryCommand(MainWindowViewModel viewModel)
        {
            this.viewModel = viewModel;
            
        }

        public override void Execute(object? parameter)
        {
            var folderDialog = new OpenFolderDialog();
            folderDialog.FolderName = viewModel.SelectedDirectory;

            var result = folderDialog.ShowDialog();
            if (result == true && !string.IsNullOrEmpty(folderDialog.FolderName))
            {
                viewModel.SelectedDirectory = folderDialog.FolderName;
            }
        }

    }
}
